///////////////////////////////////////////////////////////
//  EditTemplateCommand.cpp
//  Implementation of the Class EditTemplateCommand
//  Created on:      21-Sep-2013 12:08:33 PM
//  Original author: Jakkaphan Aiemcharoenjit
///////////////////////////////////////////////////////////

#include "EditTemplateCommand.h"
#include "CurrentCommand.h"

using namespace UI;
using namespace UI::CMD;

EditTemplateCommand::EditTemplateCommand(CCreateTemplateView* createTemplate, CTemplateView* _template)
{
  this->m_type = ICommand::EDITTEMPLATE_CMD;
  this->m_createTemplateView = createTemplate;
  this->m_templateView = _template;
}


EditTemplateCommand::~EditTemplateCommand()
{
}


void EditTemplateCommand::Execute()
{
  IPage* currentPage = this->m_templateView->GetCurSelected();
  std::string title = "Edit (" + currentPage->GetName() + ")";
  this->m_createTemplateView->SetTitleView(title);
  this->m_createTemplateView->SetPage(dynamic_cast<IPage*>(currentPage->Clone()));
  this->m_createTemplateView->Refresh();
  // Set current command
  CurrentCommand::GetInstance()->SetCurrentCommand(this->m_type);
  CurrentCommand::GetInstance()->SetNewOrEditCommand(this->m_type);
}


ICommand::CommandType EditTemplateCommand::GetType()
{
	return this->m_type;
}